package com.cheng.utli;

import com.alibaba.fastjson.JSONObject;

import java.util.UUID;

public class Utils {

    /**
     * 判断字符是否为空
     * */
    public static boolean isBlank(final CharSequence str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if (Character.isWhitespace(str.charAt(i)) == false) {
                return false;
            }
        }
        return true;
    }

    public static boolean isNotBlank(final CharSequence cs) {
        return !isBlank(cs);
    }

    /**
     * 随机生成字符串
     * */
    public static String randomString(){
        return UUID.randomUUID().randomUUID().toString().replaceAll("-","");
    }

    /**
     *
     * @Description: 判断Json对象 非空
     *
     * @param data

     */
    public static boolean isNonBlank(JSONObject data) {
        if (data==null||data.isEmpty()) {
            return false;
        }
        return true;
    }
}
